// 当前文件只是表示了一个路由关系，表示App里面有很多子组件，在App.js里面通过{this.props.children}获取
import React from 'react'
import {
		BrowserRouter as Router,//?重命名
		Switch,
		Route,
		Redirect
} from "react-router-dom";
import App from '../App';
import Home from "../views/home";
import Find from "../views/find";
import Dest from "../views/dest";
import Custom from "../views/custom";
import Personal from "../views/personal";
import Settings from "../views/settings";
import Search from "../views/search";
import Detail from "../views/detail";
import Bmdetail from '../views/bmdetail'
import {Provider} from 'react-redux'
import store from '../store'
const router = (
		// Provider这个提供器连接了store,那么Provider里面的所有的组件都有能力获取store里面的内容了
		<Provider store={store}>
		<Router>
				<App>
						<Switch>
								<Route exact path="/" component={Home}/>
								<Route path="/find" component={Find}/>
								<Route path="/dest" component={Dest}/>
								<Route path="/custom" component={Custom}/>
								<Route path="/personal" component={Personal}/>
								<Route path="/settings" component={Settings}/>
								<Route path="/search" component={Search}/>
								{/* 路由传参 */}
								<Route path="/detail/:id" component={Detail}/>
								<Route path="/bmdetail/:id" component={Bmdetail}/>
								{/* 必须放在Switch中的最后一行当用户访问某界面时，该界面并不存在，此时用Redirect重定向，重新跳到一个我们自定义的组件里 */}
								<Redirect from="*" to="/"/>
						</Switch>
				</App>
		</Router>
		</Provider>
);

export default router
